# Contributor: Justin Berthault <justin.berthault@zaclys.net>
# Maintainer: Will Sinatra <wpsinatra@gmail.com>
pkgname=py3-asttokens
pkgver=2.4.1
pkgrel=2
pkgdesc="Annotate AST trees with source code positions"
url="https://github.com/gristlabs/asttokens"
arch="noarch"
license="Apache-2.0"
depends="python3 py3-six"
makedepends="py3-gpep517 py3-setuptools_scm py3-wheel"
checkdepends="py3-astroid py3-pytest"
subpackages="$pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/a/asttokens/asttokens-$pkgver.tar.gz
	fix-setuptools-deprecation.patch
	"
builddir="$srcdir/"asttokens-$pkgver

build() {
	export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl

	case "$CARCH" in
	s390x)
		.testenv/bin/python3 -m pytest \
			--deselect tests/test_mark_tokens.py::TestMarkTokens::test_deep_recursion
		;;
	*)
		.testenv/bin/python3 -m pytest
		;;
	esac
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
5b60293e40afc42baab346b2367485f2a4dda6210bbbda53e3080ce86b05c96f928ad1eea00a2b81a2afcce626a18c8166add26bbf8b320d4f71b6fc4aa9083a  asttokens-2.4.1.tar.gz
967e339c12e4be1bb9e228055697d29ed1dd7d74ef01479befe64c755533f4df077dc6cdb4c42f191e46c4e882dc85de546c7e85012f8cc6a808e5f22f04b330  fix-setuptools-deprecation.patch
"
